/*
 * @Date: 2023-12-28 16:44:33
 * @LastEditors: lyx
 * @LastEditTime: 2024-01-27 10:48:21
 * @FilePath: \mt-middleware-server\src\feishu\store.ts
 * @Description:
 */

// 'https://applink.feishu.cn/client/mini_program/open?appId=cli_a5e43374e1e2900c&mode=appCenter&path=index';
const default_mini_url = 'https://applink.feishu.cn/client/mini_program/open';

// 'https://applink.feishu.cn/client/web_app/open?appId=cli_a5fc07626fba500b&mode=appCenter&path=showcase';
const default_h5_url = 'https://applink.feishu.cn/client/web_app/open';

// TODO: 小程序的需要调整
export const temp_test_content = (url = '', appId = '') => {
  const tUrl = `${default_mini_url}?appId=${appId}&mode=appCenter&path=${url}`;
  return {
    config: {
      wide_screen_mode: true,
    },
    elements: [
      {
        tag: 'img',
        img_key: 'img_v2_041b28e3-5680-48c2-9af2-497ace79333g',
        alt: {
          tag: 'plain_text',
          content: '',
        },
        mode: 'fit_horizontal',
        preview: true,
      },
      {
        actions: [
          {
            tag: 'button',
            text: {
              content: '去处理',
              tag: 'plain_text',
            },
            type: 'primary',
            multi_url: {
              url: tUrl,
              pc_url: '',
              android_url: '',
              ios_url: '',
            },
          },
        ],
        tag: 'action',
      },
    ],
    header: {
      template: 'turquoise',
      title: {
        content: '你有一条新的任务待处理',
        tag: 'plain_text',
      },
    },
    card_link: {
      url: tUrl,
      pc_url: '',
      android_url: '',
      ios_url: '',
    },
  };
};

/**
 * @description: 获取 h5 卡片消息 结构
 * @param {*} url lk_target_url 指定要打开网页应用的某个页面完整url  : https://open.feishu.cn/document/common-capabilities/applink-protocol/supported-protocol/open-an-h5-app
 * @param {*} appId
 * @return {*}
 */
export const h5_temp_test_content = (url = '', appId = '') => {
  const tUrl = `${default_h5_url}?appId=${appId}&mode=appCenter&lk_target_url=${url}`;
  return {
    config: {
      wide_screen_mode: true,
    },
    elements: [
      {
        tag: 'img',
        img_key: 'img_v2_041b28e3-5680-48c2-9af2-497ace79333g',
        alt: {
          tag: 'plain_text',
          content: '',
        },
        mode: 'fit_horizontal',
        preview: true,
      },
      {
        actions: [
          {
            tag: 'button',
            text: {
              content: '去处理',
              tag: 'plain_text',
            },
            type: 'primary',
            multi_url: {
              url: tUrl,
              pc_url: '',
              android_url: '',
              ios_url: '',
            },
          },
        ],
        tag: 'action',
      },
    ],
    header: {
      template: 'turquoise',
      title: {
        content: '你有一条新的任务待处理',
        tag: 'plain_text',
      },
    },
    card_link: {
      url: tUrl,
      pc_url: '',
      android_url: '',
      ios_url: '',
    },
  };
};
